// export const setItem = (key, value) => {
//     localStorage.setItem(key, JSON.stringify(value))
// }

// export const getItem = (key) => {
//     let val = localStorage.getItem(key) ? localStorage.getItem(key) : null
//     if (val) {
//         return JSON.parse(localStorage.getItem(key))
//     } else {
//         return null
//     }
// }

// export const removeItem = (key) => {
//     localStorage.removeItem(key)
// }

// export const clear = () => {
//     localStorage.clear()
// }


class Storage {
    setItem(key, value) {
        localStorage.setItem(key, JSON.stringify(value))
    }
    getItem(key) {
        let val = localStorage.getItem(key) ? localStorage.getItem(key) : null
        if (val) {
            return JSON.parse(localStorage.getItem(key))
        } else {
            return null
        }
    }
    removeItem(key) {
        localStorage.removeItem(key)
    }
    clear(key){
        localStorage.clear()
    }
}

export default Storage